package org.ourguy.mymoviesandshows.apiclient;

import java.util.ArrayList;
import java.util.Hashtable;

import org.ourguy.mymoviesandshows.datamodel.Episode;
import org.ourguy.mymoviesandshows.datamodel.ITitle;
import org.ourguy.mymoviesandshows.datamodel.Season;
import org.ourguy.mymoviesandshows.datamodel.SeasonInfo;
import org.ourguy.mymoviesandshows.datamodel.Series;

/**
 * TV Show API Driver interface.
 * @author bordjukov
 */
public interface ISeriesAPIClient extends ITitleAPIClient {
	/**
	 * Get all of the information for a given TV show, sans the list of
	 * episodes.
	 * @param id TVDB id of the show
	 * @return the TV show
	 */
	public Series getSeriesSummary(String id) throws APIException;
	
	/**
	 * Get the complete list of episodes for a TV show, ordered by season
	 * @param id The ID of the show.
	 * @return The list of seasons.
	 * @throws Throws an exception if something goes wrong.
	 */
	public ArrayList<Season> getSeasons(String id) throws APIException;
	
	/**
	 * Get the list of seasons for the specified show
	 * @param id The ID of the show.
	 * @return The season data
	 * @throws Throws an exception if something goes wrong.
	 */
	public ArrayList<SeasonInfo> getSeasonInfo(String id) throws APIException;
	
	/**
	 * Get season info of a specific season of the specified show
	 * @param id The ID of the show.
	 * @param index the consecutive number of the season
	 * @return The season data
	 * @throws Throws an exception if something goes wrong.
	 */
	public SeasonInfo getSeasonInfo(String id, int index) throws APIException;
	
	/**
	 * Get a specific season of a TV show.
	 * @param id The ID of the TV show
	 * @param index The index of the season.
	 * @return The sought season.
	 * @throws An exception if something goes wrong.
	 */
	public Season getSeason(String id, int index) throws APIException;
	
	/**
	 * Get the number of seasons of a TV Show
	 * @param id The API-Specific ID of the show
	 * @return The number of seasons
	 * @throws APIException in case something goes wrong
	 */
	public int getSeasonCount(String id) throws APIException;
	
	/**
	 * Get the number of episodes in a given season of a TV show
	 * @param id The API-Specific ID of the TV show
	 * @param season The consecutive number of the season, starting from 0
	 * @return The number of episodes
	 * @throws APIException in case something goes wrong
	 */
	public int getEpisodeCount(String id, int season) throws APIException;
	
	/**
	 * Get the index of the last season of the series
	 * @param id The API-Specific ID of the TV show
	 * @return The index of the last season
	 * @throws APIException
	 */
	public int getLastSeasonIndex(String id) throws APIException;
	
	/**
	 * Get the number of the last episode in a season of a TV show
	 * @param id The API-specific ID of the show
	 * @param season The number of the season
	 * @return the index of the last episode
	 * @throws APIException
	 */
	public int getLastEpisodeIndex(String id, int season) throws APIException;
	
	/**
	 * Get the last season of a TV show
	 * @param id the API-specific ID of the TV show
	 * @return the last season of the TV show
	 * @throws APIException
	 */
	public Season getLastSeason(String id) throws APIException;
	
	/**
	 * Get a specific episode of a season of a TV show
	 * @param id the API-specific ID of the TV show
	 * @param seasonNumber the number of the season
	 * @param episodeNumber the number of the episode
	 * @return the desired episode data
	 */
	public Episode getEpisode(String id, int seasonNumber, int episodeNumber)
			throws APIException;
	
	/**
	 * Get the last episode a specific season in a TV show
	 * @param id the API-specific ID of the TV show
	 * @param season The number of the season
	 * @return the last episode in the given season
	 * @throws APIException
	 */
	public Episode getLastEpisode(String id, int season) throws APIException;
	
	/**
	 * Get a list of episodes for a given season of a TV show
	 * @param id the API-specific ID of the TV show
	 * @param index the consecutive number of the season
	 * @return the list of episodes
	 * @throws APIException
	 */
	public ArrayList<Episode> getEpisodeList(String id, int index)
			throws APIException;
	
	/**
	 * Get a list of episodes with air date after the current date
	 * @param id the API-specific ID of the series
	 * @return the list of future episodes
	 * @throws APIException
	 */
	public ArrayList<Episode> getFutureEpisodeList(String id) throws APIException;

	/**
	 * Search for a TV show by title.
	 * @param query The title of the TV show we are looking for
	 * @return The list of TV shows that match the query
	 * @throws APIException Throws an exception if something goes wrong.
	 */
	public ArrayList<ITitle> searchSeries(String query) throws APIException;
	
	/**
	 * List of trending TV shows.
	 * @return The current list of trending TV shows. 
	 * @throws APIException Throws an exception if something goes wrong.
	 */
	public ArrayList<ITitle> getTrendingSeries() throws APIException;
	
	/**
	 * Get a slim hashtable of the apiId -> title format for a given query 
	 * @param q the string we are looking for in the series' title
	 * @return the results
	 * @throws APIException
	 */
	public Hashtable<String, String> autoCompleteSeries(String q) 
			throws APIException;
}
